#include <reg51.h>
#include "font.h"
#include "display1249.c"

#define STRING_LEN 14	// length of string
sbit CS=P2^0;		// Chip Select of Display, We control Chip here so we can add multiple CS in main.c
char msg[STRING_LEN] =  // string to display
{
	'H',
	'e',
	'x',
	's',
	'o',
	'u',
	'r',
	'c',
	'e',
	' ',
	't',
	'e',
	'c',
	'h',			
};	


/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Delay x Milisecond
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
void delay_ms(unsigned int x)	 // delays x msec (at fosc=11.0592MHz)
{
	unsigned char j=0;
	while(x-- > 0)
	{
		for (j=0; j<125; j++){;}
	}
}

void INI_1249(void)
{
   CS = 0;
   DIS_INIT_1249();         //inital 1632's set
   CS = 1;
   
   CS = 0;
   DIS_ALLRAM_1249(0);         //all LED write 0
   CS = 1;
   
}

void display(unsigned char adr, unsigned char dat)
{
   CS = 0;
   display_set(adr, dat);         //inital 1632's set
   CS = 1;		
}

void print_string()
{
	unsigned int font_pos;
	unsigned char char_pos, x, y;
	
		char_pos = 0;
	
		for(y=0; y<STRING_LEN; y++)
		{
			font_pos = (msg[y] - ' ') * 5;
	
			for(x=0; x<5; x++)
			{
				display(char_pos++, font_5x7[font_pos+x]);				
			}	
delay_ms(500);
delay_ms(500);	
delay_ms(500);
delay_ms(500);
				char_pos++;	
		}
		
}
void main()
{
	
	INI_1249();
	
	print_string();
	
	while(1)
	{
	}
}

